package maingoal;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Vector;

import com.rapidminer.RapidMiner;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.io.ModelLoader;
import com.rapidminer.tools.OperatorService;

import istar.agent.IstarJadeAgent;
import istar.behaviour.AbstractIstarBehaviour;
import istar.behaviour.IstarMainBehaviour;
import istar.impl.AbstractMainGoal;
import jade.core.behaviours.Behaviour;
import jade.core.behaviours.OneShotBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;
import log.Log;

public class BeliefBeGenerated extends AbstractMainGoal {
	
	private boolean log = true;
	
	
	public BeliefBeGenerated(IstarJadeAgent owner) {
		super("BeliefBeGenerated", owner);
		// TODO Auto-generated constructor stub
	}

	public BeliefBeGenerated() {
		super("BeliefBeGenerated");
	}


	@Override
	public Behaviour getMainBehaviour() {
		return new IstarMainBehaviour(this);
	}
	
	/*
	private class WaitingRequestOrder extends OneShotBehaviour{
		private AbstractMainGoal mainGoal;
		private int step = 0;
		
		public WaitingRequestOrder(AbstractMainGoal _mainGoal){
			super();
			mainGoal = _mainGoal;

		}

		@Override
		public void action() {
			mainGoal.clear();
			MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.REQUEST);
			ACLMessage msg = myAgent.receive(mt);
			if (msg!=null){
				String ticket = ((IstarJadeAgent)myAgent).getNextTicket();
				mainGoal.setExecutionNumber(ticket);
				log("Agent name="+ myAgent.getName() +": executing. Ticket="+ mainGoal.getExecutionNumber());
				deliberateCondition = true;
				String content = msg.getContent();
				
				mainGoal.getContent().add(content);
				((IstarJadeAgent)myAgent).setKnowledgeElement(mainGoal.getExecutionNumber(), mainGoal);
				((IstarJadeAgent)myAgent).setKnowledgeObject(mainGoal.getExecutionNumber(), "Message-Received", msg);
				log("Agent name="+ myAgent.getName() +" received a REQUEST for:" + content);
			}
			
			if (step==0){
				System.out.println(myAgent.getName()+ this.getBehaviourName() + " is executing");
				step=1;
			}
		}

		@Override
		public int onEnd() {
			//System.out.println(this.myAgent.getName() + " executing onEnd()");
			if (deliberateCondition){
				deliberateCondition = false;
				return 1;
			}
			else{
				return 0;
			}
		}
		
		private void log(String _phrase){
			if (log){
				((IstarJadeAgent)myAgent).log( _phrase);
			}
		}
	}
	*/
	
	
}
